<?php
    require_once "../../config.php";
    require_once "../../functions.php";

    //获取前端传递的分类名
    $cateId = $_POST["cateId"];
    $cateName = $_POST["editname"];
    $cateSlug = $_POST["editslug"];
    $cateClassname = $_POST["editclassname"];
    //连接数据库
    $connect = connect();
    //sql
    $editSql = "UPDATE categories set name='{$cateName}', slug = '{$cateSlug}', classname = '{$cateClassname}'  where id = {$cateId}";
    //执行sql语句,返回一个二维数组
    $result = mysqli_query($connect,$editSql);
    // print_r($result);
    //返回前端的信息提示
    $response = ["code"=>0,"msg"=>"操作失败"];
    if($result){
        $response['code'] = 1;
        $response['msg'] = "操作成功";

    }
    header("content-type:application/json;charset=ut8");
    echo json_encode($response);
?>